#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>

#include "ipc.h"

GMainLoop *loop;

GVariant *do_test1(GVariant *par){
	return g_variant_new("(bs)", TRUE, "ok");
}

void sig1(GVariant *par)
{
	//sleep(3);/*Test non-blocking signal*/
	printf("hi\n");
}

void sig2(GVariant *par)
{
	uint32_t counter;

	//printf("sig2\n");
	g_variant_get(par, "(u)", &counter);
	//g_variant_unref(par);
	ipc_raise("Sig3", g_variant_new("(u)", counter));
}

int main (void)
{
	ipc_init("test");
	ipc_add("Test1", do_test1, "(ssu)", "(bs)");
	loop = g_main_loop_new(NULL, FALSE);
	ipc_signal("test_client", "Sig1", sig1);
	ipc_signal("test_client", "Sig2", sig2);


	g_main_loop_run(loop);
	ipc_release();
	return 0;
}
